<template>
    <div class="search-box">
        <div class="inputRole">
            <div class="left">秒杀订单超过:</div>
            <el-input v-model="form.flashOrderOvertime">
                <template #append>分</template>
            </el-input>
            <div class="right">未付款，订单自动关闭</div>
        </div>
        <div class="inputRole">
            <div class="left">正常订单超过:</div>
            <el-input v-model="form.normalOrderOvertime">
                <template #append>分</template>
            </el-input>
            <div class="right">未付款，订单自动关闭</div>
        </div>
        <div class="inputRole">
            <div class="left">发货超过:</div>
            <el-input v-model="form.confirmOvertime">
                <template #append>天</template>
            </el-input>
            <div class="right">未付款，订单自动完成</div>
        </div>
        <div class="inputRole">
            <div class="left">订单完成超过:</div>
            <el-input v-model="form.finishOvertime">
                <template #append>天</template>
            </el-input>
            <div class="right">自动结束交易，不能申请售后</div>
        </div>
        <div class="inputRole">
            <div class="left">订单完成超过:</div>
            <el-input v-model="form.commentOvertime">
                <template #append>天</template>
            </el-input>
            <div class="right">自动五星好评</div>
        </div>
        <div class="elButton">
            <el-button type="primary" size="large" @click="addSubmit">提交</el-button>
        </div>
    </div>
</template>
<script setup lang='ts'>
import { ElMessage, ElMessageBox } from 'element-plus';
import { reactive } from 'vue';
import { getOrderSettingApi, getOrderSettingUpdateApi } from './api';

const form = reactive<CustomType>({
    flashOrderOvertime: 0,
    normalOrderOvertime: 0,
    confirmOvertime: 0,
    finishOvertime: 0,
    commentOvertime: 0
})

getOrderSettingApi(1).then((res) => {
    Object.assign(form, res.data)
})

const addSubmit = () => {
    ElMessageBox.confirm("是否要提交修改", "提示?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: 'warning',
    }).then(() => {
        getOrderSettingUpdateApi(form).then(res => {
            if (res.code === 200) {
                ElMessage.success('提交成功')
            }
        })
    })
}

</script>
<style lang="less" scoped>
.search-box {
    box-shadow: 0 0 4px 2px #ccc;
    border-radius: 5px;
    margin-bottom: 20px;
    width: 720px;
    padding: 35px 35px 15px 35px;
    margin: 20px auto;

    .inputRole {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;

        .left {
            font-size: 14px;
            color: #606266;
            text-align: right;
            padding: 0 12px 0 0;
            box-sizing: border-box;
            width: 120px;
            padding-right: 10px;
        }

        .right {
            width: 250px;
            padding-left: 10px;
            font-size: 14px;
        }

        :deep(.el-input-group) {
            width: 40%;
        }
    }

    .elButton {
        padding-left: 150px;
    }
}
</style>